Comparing model outputs of survey biomass.
Code
# load ----
library (dplyr)
library (ggplot2)
library (plotly)
theme_set (theme_bw ())
# data ----
# obs data
source (here:: here ('r' , 'bridge_data.r' ))
# admb model output
admb = read.csv (here:: here ('data' , 'admb' , 'survey.csv' ))
# rtmb model output
report1 = readRDS (here:: here ('data' , 'rtmb' , 'report1.rds' ))
data.frame (year = srv_yrs,
biomass = srv_obs,
sd_2022 = srv_sd,
rtmb_2022 = report1$ srv_pred,
admb_2022 = admb$ pred) %>%
mutate (lci_2022 = biomass - 1.96 * sd_2022,
uci_2022 = biomass + 1.96 * sd_2022) %>%
tidyr:: pivot_longer (c (rtmb_2022, admb_2022), names_to= 'model' ) %>%
ggplot (aes (year, biomass)) +
geom_point (color= 'gray' ) +
geom_errorbar (aes (ymin = lci_2022, ymax = uci_2022), width= .2 , color= 'gray' ) +
expand_limits (y= 0 ) +
scale_y_continuous (labels = scales:: comma) +
geom_line (aes (y = value, color = model)) +
scico:: scale_color_scico_d (palette = 'roma' ) +
xlab ('Year' ) +
ylab ('Biomass (t)' ) -> p1
ggplotly (p1)
One can click on the model names in the legend to add/remove from the figure.